
# 1）
class Employee:
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary

    def calculate_pay(self):
        print(self.salary)
        # return self.salary

# 任务1：创建Manager类继承Employee
# 添加bonus属性
# 重写calculate_pay()方法计算总薪资(salary + bonus)
class Manager(Employee):
    def __init__(self, name, salary,bonus):
        super().__init__(name,salary)
        self.bonus = bonus
    def calculate_pay(self):
        super().calculate_pay()
        print(f"总薪资{self.salary + self.bonus}")
        # return f"总薪资{self.salary + self.bonus}"
a = Employee("周勇强",3000)
a.calculate_pay()
b = Manager("周勇强",5000,3000)
b.calculate_pay()
# 任务2：创建HourlyEmployee类继承Employee
# 添加hours_worked属性
# 重写calculate_pay()方法计算时薪(salary // hours_worked)
class HourlyEmployee(Employee):
    def __init__(self, name, salary,hours_worked):
        super().__init__(name,salary)
        self.hours_worked = hours_worked
    def calculate_pay(self):
        super().calculate_pay()
        print(f"时薪{self.salary // self.hours_worked}")
        # return f"总薪资{self.salary + self.bonus}"
c = HourlyEmployee("周勇强",3000,20)
c.calculate_pay()

# 2）设计一个简单的游戏系统，包含不同类型的角色
# （战士、法师、射手），每个角色都有attack()方法，
# 但实现方式不同。请用代码展示如何利用多态来实现这个系统。
class Game:
    def __init__(self,name):
        self.name = name
    def attack(self):
        print("攻击方式")

class Warrior(Game):
    def __init__(self,name,type):
        super().__init__(name)
        self.type = type

class Mage(Game):
    def __init__(self,name,type):
        super().__init__(name)
        self.type = type

class Shooter(Game):
    def __init__(self,name,type):
        super().__init__(name)
        self.type = type

def method(game:Game): # int str list  shape1代表一个对象
    print(game.name,game.type)

a = Game("游戏")
a.attack()
b = Warrior("战士","近身战斗")
c = Mage("法师","远程魔法球")
d = Mage("射手","远程设计")
method(b)
method(c)
method(d)

# __init__()和__init__.py有什么不同，分别是什么？
# 面向对象的特征分别是什么
# 你都用过哪些常见的模块，都分别有什么功能